using System;
using System.IO;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using BusinessLibrary;
using System.Reflection;

namespace AndroidClient
{
	[Activity (Label = "AndroidClient", MainLauncher = true)]
	public class Activity1 : Activity
	{
		int count = 1;

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Set our view from the "main" layout resource
			SetContentView (Resource.Layout.Server);
			
			InitProgram();

			// Get our button from the layout resource,
			// and attach an event to it
			Button button = FindViewById<Button> (Resource.Id.myButton);
			
			button.Click += delegate
			{
				StartNewActivity();
				//button.Text = string.Format ("{0} clicks!", count++); 
			};
		}

		protected void InitProgram ()
		{
			if(!Directory.Exists(Config.savePath))
			{
				Directory.CreateDirectory(Config.savePath);
			}
			
			FtpClient client = new FtpClient(Config.serverIP, Config.serverIP, "ftp", "ftp");
			client.fileDownload(Config.savePath, "abc.jpg", string.Empty, "abc.jpg");		
			
			//StartNewActivity();
		}
		
		protected void StartNewActivity()
		{
			var activity2 = new Intent (this, typeof(Display));
  	        activity2.PutExtra ("MyData", "Data from Activity1");
	        StartActivity (activity2);  
		}
	}
}


